## 12.2. Sharing Programs

The most popular non-Linux operating systems where compatibility is important--where people want to run its programs and files on Linux--are derivates of DOS: MS-DOS, PC-DOS, Novell DOS, and Windows 3.1 and later. You can use the Linux MTools package to search DOS filesystems, read and copy files, and write to a DOS filesystem. Still, compatibility with DOS obviously requires a lot more than handling a DOS filesystem.

There are two packages intended to provide Linux with the desired DOS compatibility. One is Dosemu and the other is Wine. We discuss them both in this chapter because of their importance to the Linux community.

It should be noted, though, that neither Dosemu nor Wine are finished products. While both development teams have made amazing progress, given the difficulty of their task, you should use them currently only if you are willing to fiddle around with them, trying to reconfigure things, and perhaps even trying to find and fix bugs. If you'd rather try a finished, commercial product, you can buy WABI (Windows Application Binary Interface) from Caldera, Inc., which is a port of the same product for Solaris and is quite stable, but it can run only Windows 3.1 programs.

Another remark: Two years ago, binary emulators like Dosemu and Wine were of utmost importance to the Linux community, because there was not much commercial software available. This situation has utterly changed, however. Many commercial software vendors are providing their products for Linux now, so you might be able to get what you want without running an emulator. Remember that emulation takes its toll; no emulated program can be faster or more stable than a native one.

Recently, new life was breathed into Wine because Corel announced that they would port their products (like CorelDRAW) to Linux by means of Wine, that is, they would support the further development of Wine. This is a notable acceptance of the outstanding work of the Wine team, but it remains to be seen whether these plans will be successful.

The development teams working on Dosemu and Wine are delighted to encourage more developers to pitch in and help, but if you are simply an end user, or a programmer with no access to the Internet and thus no ready access to the developer community, these packages may not be right for you.

There are also emulators for the Apple II and CP/M operating systems, as well as many other machines long forgotten by most users. They originally were run on other operating systems (such as MS-DOS) and have now been ported to Linux. You can get them from the usual Linux FTP sites that archive the emulator software, which are primarily ftp://ftp.metalab.unc.edu and its mirror sites in the path /pub/Linux/system/emulators.

A demo of a commercial (but low-priced) Macintosh emulator is also available from http://www.ardi.com called Executor/Linux. This is a Linux version of a package that has been offered for several years on NeXT machines, and for more than a year on DOS machines. You might try it if only to gain the ability to read and write Mac floppy and SCSI disk formats, which the demo package provides. (The developers of this product have announced that they will release the source code for their Mac file browser to the public.)

If you want to keep up with developments on Executor/Linux, send mail to majordomo@nacm.com with nothing in the `Subject:` field, and with the message text `subscribe executor`.

### 12.2.1. DOS Emulators: Dosemu and xdos

First, we should make it clear that Linux's "DOS emulators," the Dosemu and `xdos` packages, aren't really emulators. They can be considered virtual machines that allow DOS and applications running on DOS to execute in real mode (virtual 8086 mode) in a "compatibility box" environment similar to the operation of DOS on a standard Intel 80286 or 80386. Because a necessary element of the compatibility box is the virtual 8086, only chipsets that implement the Intel real mode will ever have Dosemu or `xdos` ported to them. `xdos` is just a convenient wrapper for Dosemu that lets you run it in an X window, so for this discussion we'll focus primarily on Dosemu.

You should have 8 MB of RAM to use Dosemu, and it would be wise to also have a 12 MB swap partition set up on the hard disk.

Dosemu emulates the BIOS, CMOS memory, XMS and EMS memory, disk services, keyboard, serial devices and printer, and other necessary machine functions, letting DOS work in this controlled environment. Dosemu requires that you have a (licensed) copy of either OpenDOS (formerly known as DR-DOS) or MS-DOS 6.22, but other versions might work as well. Since OpenDOS is freely available, it is preferred by the Dosemu developers.

Dosemu tries to trap DOS and BIOS system calls and handle them in Linux, but it isn't always successful in doing this. DOS BIOS printer services are emulated with Unix file I/O, with the output intended for a printer spooled to a corresponding Linux file. Dosemu has problems with mouse support for some mice, particularly busmouse systems.

We don't encourage you to use Dosemu unless you are willing and able to contribute to the further development of the package and have Internet access to work with the development team. However, Dosemu appears to be useful enough and stable enough to justify discussing it as a package you should consider installing. You should be aware, though, that the development of documentation for Dosemu lags behind the development of software. If you aren't involved in Dosemu development, you may find it difficult to use new features; they may not be that safe anyhow.

More recent versions of Dosemu include some functions originally developed as part of Carnegie Mellon University's DOS emulator for Mach, so Dosemu distributions include the nonrestrictive CMU copyright notice. This notice asks that developers who build software using CMU's work provide a copy of their work to CMU and allow CMU the right to use and redistribute it. (The copyright notice requires that their notice be reproduced and included in any distribution that uses their software, whether or not their code is modified.) You should honor CMU's copyright, so if you will participate in developing Dosemu, be sure to read and observe its copyright notice.

The Dosemu package includes scripts and utilities to install and maintain the package. Dosemu is updated weekly, and each distribution includes a list of software known to run (or not to run) with the current release of the package.

### 12.2.2. Getting Dosemu and xdos

The FTP site guaranteed to maintain the latest public version of the Dosemu package is ftp://tsx-11.mit.edu. The files can be found in the /pub/linux/ALPHA/dosemu directory. ("Alpha" refers to the state of development of the application, not to a distribution for Alpha architecture Linux.) This includes the most recent documentation files.

Dosemu does not itself support compressed filesystems, but you can use a special driver in the Linux kernel that can mount compressed filesystems and then access those mounted filesystems from within Dosemu.

### 12.2.3. Installing and Configuring Dosemu

Before you install the Dosemu package, you must first compile the Linux kernel with IPC (System V InterProcess Communication facilities). If you did not build Linux with IPC during the configuration process when installing Linux, you will have to rebuild the kernel to add the facilities before installing Dosemu, which uses System V-shared memory. We strongly recommend that you use a current release of Linux as a basis for running Dosemu and compile Dosemu with a current `gcc` compiler and libraries. Linux 2.0.28/2.1.15 and later include the needed kernel support for Dosemu.

You must have `gcc` Version 2.7.2 and `libc` Version 5.4.7 or later for this version of Dosemu. Later versions of Dosemu may require later versions of Linux, `gcc`, and C libraries.

Boot Linux and login as root. Place the Dosemu package in the / root directory and unpack it. (The Dosemu package name may vary from this example, whose name reflects our downloading the file via DOS before copying it into the Linux filesystem):

>     # gunzip dosemu-0.98.4.tgz
>     # tar -xvf dosemu-0.98.4.tar

The files unpack into the directory dosemu-0.98.4 and its subdirectories.

Now read the documentation. A Dosemu HOWTO file comes with the distribution package in the /dosemu-0.98.4/doc directory. Also read the file QuickStart that comes with the distribution. A script ViewDocs provided with Dosemu lets you view the documentation comfortably.

A file named DANG (Dosemu Novice's Altering Guide) contains notes for customizing source code. This file is extracted automatically from the source code itself, at each release. Additionally, the `dos(1)` manual page describes the state of the `dos` command for your version of Dosemu. There is a Texinfo document for Dosemu (dosemu.texinfo) that lags well behind the current state of development of the package. It contains information useful in preparing to install the Dosemu package.

If you need to rebuild your kernel to add IPC and DOS filesystem support and to install a kernel patch, do it now.

Still as root, go to the dosemu-0.98.4 directory and verify that the distribution Makefile exists there. Enter the commands:

>     # make
>     # make install

You can now try your newly installed Dosemu with a tiny provided FreeDOS image by issuing:

>     # ./first-test
>     C:> exitemu

If this works for you, your Dosemu is probably built correctly.

Next, you will have to copy and edit some configuration files:

- Copy the file etc/dosemu.conf to /etc/dosemu.conf and modify this file according to the documentation. Be sure to read the documentation, especially the file doc/README.txt to do this. You might also want to leave it as it is for now and come back here once you have gotten a little bit more feel for Dosemu.

- Depending on your security needs, copy either etc/dosemu.users.easy or etc/dosemu.users.secure to /etc/dosemu.users and edit this file according to your needs.

Next, you need to create a DOS boot image. If you have a contemporary version of the MTools package (Version 3.8 or newer) and a bootable DOS partition or DOS boot floppy, you can run the program setup-hdimage provided with the Dosemu distribution as in the following example:

>     tigger: # ./setup-hdimage
>     checking your partitions, wait...
>     ...done
>     I've seen the following DOS partitions (perhaps non-bootable):

>          /dev/sdc1

>     If none of them are valid, you can continue any way using a bootable
>     floppy as input. Which one do you want to use as input?
>     Type in the full device name or ENTER to cancel

>     /dev/fd0

>     A normal MSDOS system has command.com as shell.
>     If you have a different one, please enter the name,
>     else just type ENTER

>     We now try to generate a bootable hdimage into /var/lib/dosemu/
>     hdimage.first and are calling ./dexe/mkdexe for this.

>     You will be prompted to edit the configuration files
>     (config.sys, autoexec.bat e.t.c).

>     Enter the name of your favorite editor, if you type just ENTER, the
>     editor given via the EDITOR environment variable will be used.

>     Starting ...
>     System type is IBMorOpenDos. sysfiles: ibmbio.com, ibmdos.com, command.com
>     1+0 records in
>     1+0 records out
>     Cannot create entry named . or ..

>     Skipping "config.sys", is not a directory

>     Skipping "autoexec.bat", is not a directory
>      ... done

In this case, we use a bootable OpenDOS floppy disk. If everything goes well, the file /var/lib/dosemu/hdimage.first should be generated and contain your DOS boot image. If there are problems, you might need to use the old method of creating a boot image; see the file doc/README-tech.txt, section 7, in the Dosemu distribution.

Next, check that there is a line like:

>     $_hdimage = "hdimage.first"

in your /etc/dosemu.conf. There can be more than one image file present here, but hdimage.first should be the first one mentioned.

Now you are ready to start your Dosemu with:

>     dosemu -C

Dosemu should come up with something like:

>     Linux DOS emulator 0.98.4.0 $Date: 2001/06/18 18:18:10 $
>     Last configured at Mon Mar 22 13:05:19 CET 1999 on linux
>     This is work in progress.
>     Please test against a recent version before reporting bugs and problems.
>     Bugs, Patches & New Code to linux-msdos@vger.rutgers.edu

>     Starting DOS...

>     [Host File System] drive D: is directory /
>     [dosemu EMS 4.0 driver installed]

>     Caldera OpenDOS 7.01
>     Copyright (c) 1976, 1997 Caldera, Inc.
>     All rights reserved.

>     "Welcome to dosemu 0.98!"
>     C:\>

Now you are ready to try your DOS emulator. Be sure to read the documentation to see the many possibilities of configuring Dosemu. By editing /etc/dosemu.conf, you can quickly solve problems that occur with specific DOS software, terminal modes, sound system support, and the like. You can add pointers to additional DOS directories on hard disks. When you are done working with Dosemu, you can exit it with:

>     C:\> exitemu

If you want to start Dosemu in an X window of its own, you can run the program `xdos` instead. You might need to execute:

>     xset fp rehash

first to make the newly installed DOS fonts available.

If you are adventurous, you can now even try to run Windows 3.x in real mode by installing it into your DOS hard-disk image and then typing:

>     win /r

### 12.2.4. Windows Emulation: Wine

Wine is the most ambitious DOS/Windows compatibility package, and it bears tremendous potential value to the Linux community. Wine is inspired by WABI, which originally was developed by Sun Microsystems to allow Microsoft Windows packages to run directly on Solaris. WABI has been licensed by Sun to other System V ports to the Intel PC, and a WABI development group comprised of several Unix vendors guides further the development of WABI. No Linux vendor that we are aware of is a member of the WABI development group. However, Caldera has licensed WABI from SunSoft. The WABI specifications are made available to the public, and the Linux Dosemu team has applied them to the Wine development effort. Wine is being developed for Linux, NetBSD, and FreeBSD at this time, and the first commercial support has been announced by Corel.

You need at least 16 MB of RAM to use Wine, and at least a 32 MB swap partition set up on the hard disk.

Wine consists primarily of a program loader that loads and executes 16-bit MS Windows application binaries and an emulation library that translates calls to MS Windows functions and translates them into Linux and X Window System function calls. As the Wine FAQ notes, Wine means either "WINdows Emulator, or Wine Is Not an Emulator. Both are right." When Wine is fully developed, most Windows applications will run under Wine in the Linux/X environment and will run about as fast under Wine as they do under windows. Maybe faster. A Linux-supported graphics coprocessor makes the X Window System perform a lot better and therefore makes a big difference to Wine performance.

At the time of this writing, Wine support for the Win32 ABI (used by 32-bit Windows 95 and NT applications) is progressing. Ultimately, Wine developers hope that it will be able to run both 16- and 32-bit Windows applications.

Wine is filesystem independent and can be used on any Linux (or Unix) filesystem. You must use the X Window System to run Wine; Wine is invoked from a window opened by your favorite Linux window manager:

>     wine /pathname/winapp.exe

where pathname is either a Linux- or a DOS-style pathname and winapp.exe is a Windows-based executable.

We can't encourage you to use Wine at this time unless you are a programmer who will contribute to the further development of this ambitious package. Wine is very much in alpha-stage development. As of this writing, Wine does not implement all of the MS-Windows application programming interface (API) functions. Because we think you won't be able to use Wine effectively at this stage unless you are a programmer with Internet access who can contribute to the project, we don't discuss how to install and configure Wine.

If you want to join the Wine developers team or are just looking for more information, your best bet is to check the Wine Headquarters web site at http://www.winehq.com; this is also where you can download the most current version of Wine.

Copyright © 2001 O'Reilly & Associates. All rights reserved.